package com.sheep.jucdemo.part11.part11_4;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @Date 2022/5/24 23:44
 * @Created by sheep
 */
public class Test11_4_1_2 {
    // 创建单例实例
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static void main(String[] args) {
        // 创建多个线程启动
        for (int i = 0; i < 10; ++i) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        synchronized (sdf){
                            System.out.println(sdf.parse("2022-05-24 23:35:27"));
                        }
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                }
            });
            // 启动线程
            thread.start();
        }
    }
}
